package com.lanhao.aot.completefuture;

import java.util.concurrent.CompletableFuture;

public class CompleteFutureUtil {
	public static void main(String[] args) {
		thenApply();
	}
	
	public static void supplyAsync() {
		CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			return "SupplyAsync Test!!";
		});
		System.out.println(future.join());
	}
	
	
	public static void thenApply() {
		CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
			return "SupplyAsync Test!!";
		});
		CompletableFuture<String> future2 = future.thenApply((p) -> {
			return p + " thenApply!!!";
		});
		
		System.out.println(future2.join());
	}
}
